<!--
档案管理-档案管理
 add by yyp 2020-01-10
-->
<template lang="pug">
  keep-alive
    kalix-table(bizKey="File" title='档案管理' ref="kalixTable"
    v-bind:tableFields="tableFields"
    v-bind:targetURL="FileURL"
    v-bind:bizDialog="fileDialog"
    v-bind:btnList="fileBtnList"
    v-bind:toolbarBtnList="toolbarBtnList"
    v-bind:customRender="showChapter"
    bizSearch="fileSearch")
      template(slot="tableColumnSlot")
        el-table-column(prop="cname" label="切片类别" align="center")
        el-table-column(prop="name" label="病患姓名" align="center")
        el-table-column(prop="pathologyNum" label="病理号" align="center")
        el-table-column(prop="doctor" label="申请医师" align="center")
        el-table-column(prop="unitName" label="原切片单位" align="center")
        el-table-column(prop="applicationTime" label="申请时间" align="center")
          template(slot-scope="scope")
            span {{dataFormat(scope.row.applicationTime)}}
        el-table-column(prop="diagnosis" label="临床诊断" align="center")
        el-table-column(prop="status" label="报告状态" align="center")
</template>

<script type="text/ecmascript-6">
  import {FileURL, ClassURL, HospitalURL} from '../../config.toml'
  import {fileConfigBtnList} from './config'
  import KalixTable from '../../../../../components/corelib/components/common/baseTable'

  export default {
    name: 'kalix-telemedicine-file',
    components: {KalixTable},
    data() {
      return {
        FileURL: FileURL,
        tableFields: [
          {prop: 'cname', label: '切片类别'},
          {prop: 'name', label: '病患名称'},
          {prop: 'pathologyNum', label: '病理号'},
          {prop: 'doctor', label: '申请医师'},
          {prop: 'hospitalName', label: '原切片单位'},
          {prop: 'applicationTime', label: '申请时间'},
          {prop: 'diagnosis', label: '临床诊断'},
          {prop: 'status', label: '报告状态'}
        ],
        fileDialog: [
          {id: 'view', dialog: 'fileView'}
        ],
        fileBtnList: fileConfigBtnList,
        toolbarBtnList: [
          {id: 'add', isShow: false, title: '添加', icon: 'icon-pinleizengjia', isPermission: false}
        ]
      }
    },
    mounted() {
      this.getClassType()
      this.getHospital()
    },
    methods: {
      getClassType() {
        this.axios.request({
          method: 'GET',
          url: ClassURL
        }).then(res => {
          this.claName = res.data.data
        })
      },
      getHospital() {
        this.axios.request({
          method: 'GET',
          url: HospitalURL
        }).then(res => {
          this.HoName = res.data.data
        })
      },
      dataFormat(val) {
        let d = new Date(val)
        return this.$M_FormatDate(d, 'yyyy-MM-dd hh:mm:ss')
      },
      showChapter(_data) {
        let data = this.$refs.kalixTable.tableData
        // 档案分类
        for (let i = 0; i < data.length; i++) {
          for (let j = 0; j < this.claName.length; j++) {
            if (data[i].cid === this.claName[j].id) {
              this.$refs.kalixTable.tableData[i].cname = this.claName[j].className
            }
          }
        }
        // 原切片单位
        for (let i = 0; i < data.length; i++) {
          for (let j = 0; j < this.HoName.length; j++) {
            if (data[i].unit === this.HoName[j].id) {
              this.$refs.kalixTable.tableData[i].unitName = this.HoName[j].hospitalName
            }
          }
        }
      }
    }
  }
</script>

<style scoped lang="stylus">

</style>
